Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Had to change the chat_app FastAPI Example to get it to work after copying #295

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ferrants
Copy link

@ferrants ferrants commented Dec 17, 2024

I copied to examples:

python -m pydantic_ai_examples --copy-to examples/

And then tried to run it:

python examples/chat_app.py 

But had it surfacing an error ending with (adding this so someone finds this when searching)

pydantic.errors.PydanticUserError: Dataclass 'ModelRequest' needs a discriminator field for key 'message_kind'

And upon editing the file to remove the MessageTypeAdapter, I saw that it wasn't being used because uvicorn pointed to the installed version, not the current file version. Once I made this change, I was able to run this example.

)
# MessageTypeAdapter: TypeAdapter[ModelMessage] = TypeAdapter(
# Annotated[ModelMessage, Field(discriminator='message_kind')]
# )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think this is a mistake, and should be uncommented, also this is where the conflicts are coming from.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants